
#include <cstdio>
#include <memory>

#include "Bsp.hpp"
#include "QHsmTst.hpp"

using namespace QP;
using namespace QHSMTST;

int main(int argc, char const *argv[]) {
  /* code */
  QHSMTST::BSP_init();
  printf(
      "QHsmTst example, built on %s at %s\n"
      "QEP: %s.\nPress ESC to quit...\n",
      __DATE__, __TIME__, QP::QEP::getVersion());
  the_hsm->init();  // trigger the initial tran. in the test HSM
  for (;;) {
    printf("\n>");
    int c = getchar();  // get a character from stdin
    printf(": ");
    std::shared_ptr<const QEvt> e;
    if ('a' <= c && c <= 'i') {
      e = std::make_shared<QEvt>(c - 'a' + A_SIG);
    } else if ('A' <= c && c <= 'I') {
      e = std::make_shared<QEvt>(c - 'A' + A_SIG);
    } else if (c == '\33') {  // the ESC key?
      e = std::make_shared<QEvt>(TERMINATE_SIG);
    } else {
      e = std::make_shared<QEvt>(IGNORE_SIG);
    }
    the_hsm->dispatch(e);
  }

  return 0;
}
